<template>
	<view class="coupon">
		<view class="p2 ccoupon">
			<my-coupon @change='radioChange' @btntap='btntap(v.id)' :color='tColor' cname='mb30' v-for="(v,i) in tList" :key='i' :co='v.coupon' :v="v" ptype='2'></my-coupon>
			<view class="f15 wei c9 mt20 mb20">不可用优惠券</view>
			<my-coupon :color='tColor' cname='mb30' v-for="(v,i) in fList" :key='i' :co='v.coupon' :v="v" ptype='3'></my-coupon>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapActions
	} from 'vuex'
	import myCoupon from '@/components/common/my-coupon.vue'
	// import utils from '@/common/utils.js'
	// import {
	// 	sljz
	// } from "@/common/util-mixins.js"
	export default {
		name: 'coupon-list',
		components: {
			myCoupon,
		},
		data() {
			return {
				show: false,
				params: {
					page: 1,
					size: 10,
				},
				tList:[],
				fList:[],
			}
		},
		onLoad(options) {
			let arr = uni.getStorageSync('kyhb')
			if (options.couponId) {
				for (let i in arr.true) {
					if (options.couponId == arr.true[i].id) {
						arr.true[i].checked = !arr.true[i].checked
					} else {
						arr.true[i].checked = false
					}
				}
			}
			this.tList = arr.true
			this.fList = arr.false
			this.query = options
		},
		// mixins: [sljz],
		computed: {},
		methods: {
			async btntap(e) {
				
			},
			radioChange(e) {
				let arr = this.tList
				for (let i in arr) {
					if (e == arr[i].id) {
						arr[i].checked = !arr[i].checked
					} else {
						arr[i].checked = e == arr[i].id
					}
				}
				let i = arr.find(v => v.checked == true)
				uni.$emit('payorder', {
					hbInfo: i,
					type: this.query.t,
				});
				uni.navigateBack({
					delta: 1
				})
			},
		},
	}
</script>
<style scoped lang="scss">
	.coupon {
		.ccoupon {

			.left {
				width: 30%;
			}

			.qsy {
				width: 130rpx;
				height: 56rpx;
			}

			.criel {
				width: 36rpx;
				height: 36rpx;
				background: #eee;
			}

			.fanz {
				transform: rotateZ(180deg);
			}

			.fanzz {
				transform: rotateZ(0deg);
			}

			.lh40 {
				line-height: 48rpx;
			}
		}
	}
</style>